package com.pxmeta.user.converter;

import cn.hutool.core.collection.CollectionUtil;
import com.google.common.collect.Lists;
import com.pxmeta.user.entity.User;
import com.pxmeta.user.entity.UserBill;
import com.pxmeta.user.entity.dto.UserDTO;
import com.pxmeta.user.entity.vo.UserBillVO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class UserBillConverter {

    public static UserBillVO toVo(UserBill userBill){
        UserBillVO vo = new UserBillVO();
        BeanUtils.copyProperties(userBill,vo);
        return vo;
    }

    public static List<UserBillVO> toVoList(List<UserBill> userBills){
        if (CollectionUtil.isEmpty(userBills)){
            return new ArrayList<>();
        }
        LinkedList<UserBillVO> list = Lists.newLinkedList();
        for (UserBill userBill : userBills) {
            UserBillVO userBillVO = toVo(userBill);
            list.add(userBillVO);
        }
        return list;
    }
}
